/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023-2023.
 * Description: provide security feature boot optimization
 * Author: xiongshenglan <xiongshenglan@huawei.com>
 * Create: 2023-08-03
 */
#include <linux/string.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/moduleparam.h>
#include <linux/rtos_boot_optimization.h>

bool rtos_ima_enabled = true;
bool rtos_audit_enabled = true;
bool rtos_hkids_enabled = true;
bool rtos_selinux_enabled = true;

module_param_named(ima_enabled, rtos_ima_enabled, bool_enable_only, 0640);
module_param_named(audit_enabled, rtos_audit_enabled, bool_enable_only, 0640);
module_param_named(hkids_enabled, rtos_hkids_enabled, bool_enable_only, 0640);
module_param_named(selinux_enabled, rtos_selinux_enabled, bool_enable_only, 0640);

static void sec_log(const char *sec_str)
{
	pr_info("light_sec has set %s. Disable %s. Please enable %s through file interface after boot.\n",
		sec_str, sec_str, sec_str);
}

static int __init kernel_light_sec_setup(char *cmdline_light_sec)
{
	char *str = cmdline_light_sec;
	char *arg;

	while ((arg = strsep(&str, ",")) != NULL) {
		if (strcmp(arg, "ima") == 0) {
			sec_log("ima");
			rtos_ima_enabled = false;
		}
		if (strcmp(arg, "audit") == 0) {
			sec_log("audit");
			rtos_audit_enabled = false;
		}
		if (strcmp(arg, "hkids") == 0) {
			sec_log("hkids");
			rtos_hkids_enabled = false;
		}
		if (strcmp(arg, "selinux") == 0) {
			sec_log("selinux");
			rtos_selinux_enabled = false;
		}
	}

	return 1;
}
__setup("light_sec=", kernel_light_sec_setup);

